<script>
import GmTable from "@/view/components/gmTable.vue";

export default {
  components: {
    GmTable: GmTable
  },
  watch: {
    // 监听路由对象$route的变化
    '$route': {
      handler: function (to, from) {
        // 路由发生变化时的处理逻辑
        if (to.path === '/base/classList') {
          this.tableConfig.classCode = this.$route.params.classCode;
          this.tag = Math.random();
        }
      },
      // 设置为深度监听
      deep: true
    }
  },
  data() {
    return {
      tag: Math.random(),
      tableConfig: {
        control: 't-class',
        mainKey: 'classCode', //数据主键，用于删除该条数据
        needDist: true,
        classCode: ''
      },
      tableColumns: [{
        name: 'schoolName',
        label: '学校名称',
        id: 'schoolName',
        search: false,
        addHide: true,
        searchType: 'select',

      }, {
        name: 'schoolCode',
        label: '学校名称',
        id: 'schoolCode',
        search: true,
        hide: true,
        required: '/t-school/findPageAuth?current=1&size=100',
        searchType: 'select',
        props: {
          label: 'schoolName',
          value: 'schoolCode'
        }
      }, {
        name: 'className',
        label: '班级名称',
        id: 'className',
        search: false,
        required: false,
        searchType: 'input',
      }, {
        name: 'schoolGrade',
        label: '入学年份',
        id: 'schoolGrade',
        search: false,
        required: false,
        searchType: 'year',
      }, {
        name: 'classBoardingArrangement',
        label: '学校居住安排',
        id: 'classBoardingArrangement',
        search: true,
        searchType: 'select',
        required: '/common/getItem/live',
      }, {
        name: 'grade',
        label: '年级',
        id: 'grade',
        search: false,
        searchType: 'input',
        addHide: true,
      },
        {
        name: 'createDate',
        label: '创建时间',
        id: 'createDate',
        search: false,
        searchType: 'state',
        addHide: true,
      }, {
        name: 'createUserName',
        label: '创建人',
        id: 'createUserName',
        search: false,
        searchType: 'state',
        addHide: true,
      }, {
        name: 'state',
        label: '状态',
        id: 'state',
        search: false,
        required: '/common/getItem/state',
        searchType: 'state',
      }],
    }
  },
}
</script>

<template>
  <div class="page-car">
    <gm-table :key="tag" :table-columns="tableColumns" :table-config="tableConfig"></gm-table>
  </div>
</template>

<style scoped>

</style>
